package com.dataseek.iot.mysql.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dataseek.iot.mysql.entity.Province;
import com.dataseek.iot.mysql.mapper.ProvinceMapper;
import com.dataseek.iot.mysql.service.IProvinceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author cc
 * @since 2021-10-26
 */
@Service
public class ProvinceServiceImpl extends ServiceImpl<ProvinceMapper, Province> implements IProvinceService {

    /**
     * 根据code获取信息
     * @param code
     * @return
     */
    public Province getOneByCode(String code){
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("province_code", code);
        return getOne(wrapper);
    }

    /**
     * 验证是否存在
     * @param code
     * @return
     */
    public Boolean isExisted(String code){
        Object o = getOneByCode(code);
        return Objects.nonNull(o)? true : false;
    }


}
